function p = prdisc(sd,md,rv,disc,basis)
%PRDISC Price of discounted security.
%   Returns the price of a discounted security given the settlement date
%   SD, the maturity date MD, redemption value RV, discount rate DISC, and
%   day-count basis.
%
%   P = PRDISC(SD,MD,RV,DISC)
%   P = PRDISC(SD,MD,RV,DISC,BASIS)
%
%   Enter dates as serial date numbers or date strings.
%
%   Inputs:
%       SD      -  Settlement date
%       MD      -  Maturity date
%       RV      -  Redemption value
%       DISC    -  Discount rate
%
%   Optional Inputs:
%       basis   -  the day-count basis:
%                  0 = actual/actual (default)
%                  1 = 30/360 SIA
%                  2 = actual/360
%                  3 = actual/365
%                  4 = 30/360 PSA
%                  5 = 30/360 ISDA
%                  6 = 30E/360
%                  7 = actual/365 Japanese
%                  8 - actual/actual ISMA
%                  9 - actual/360 ISMA
%                 10 - actual/365 ISMA
%                 11 - 30/360 ISMA
%                 12 - actual/365 ISDA
%
%   Using the following data,
%
%       SD = '10/14/1988'
%       MD = '03/17/1989'
%       RV = 100
%       disc = 0.087
%       basis = 2
%
%   p = prdisc(sd,md,rv,disc,basis)
%
%   returns p = 96.28
%
%   See also PRBOND, PRMAT, YLDDISC.
%
%   Reference: Mayle, Standard Securities Calculation Methods, Volumes
%              I-II, 3rd edition.  Formula 2.

% Copyright 1995-2006 The MathWorks, Inc.
% $Revision: 1.6.2.8 $   $Date: 2009/05/07 18:23:31 $

% Default day count basis
if nargin < 5
    basis = zeros(size(rv));
end

if nargin < 4
    error('finance:prdisc:notEnoughInputs',...
        'Missing one of SD, MD, RV, and DISC.');
end

[~, sd, md, ~, basis, ~, ~, ...
    ~, ~, ~, ~] = ...
    instargbond([],sd,md,[],basis,[],[],[],[],[],rv);

[sd,md,rv,disc,basis] = ...
    finargsz(1,sd,md,rv,disc,basis);

% Formula 2
p = reshape(rv-(disc.*rv.*yearfrac(sd,md,basis)),size(rv));